using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Entity class containing profile of account
/// </summary>
public class Account: IBusinessEntity
{
    private string _username;
    private string _password;
    private string _fullname;
    private string _address;
    private string _email;
    private string _phoneNumber;
    private string _pinCode;
    private string _role;
    private bool _isWorking;
    private string _branchName;

  

    public Account()
    {
        _username = "";
        _password = "";
        _fullname = "";
        _address = "";
        _email = "";
        _phoneNumber = "";
        _pinCode = "";
        _role = "";
        _isWorking = true;
        _branchName = "";
    }

    /// <summary>
    /// Name of the branch where user is working
    /// </summary>
    public string BranchName
    {
        get { return _branchName; }
        set { _branchName = value; }
    }

    /// <summary>
    /// Define whether the owner of this account is working or not
    /// </summary>
    public bool IsWorking
    {
        get { return _isWorking; }
        set { _isWorking = value; }
    }

    /// <summary>
    /// Role of account
    /// </summary>
    public string Role
    {
        get { return _role; }
        set { _role = value; }
    }

    /// <summary>
    /// PinCode of the branch where user is working
    /// </summary>
    public string PinCode
    {
        get { return _pinCode; }
        set { _pinCode = value; }
    }

    /// <summary>
    /// PhoneNumber of user
    /// </summary>
    public string PhoneNumber
    {
        get { return _phoneNumber; }
        set { _phoneNumber = value; }
    }

    /// <summary>
    /// Email of user
    /// </summary>
    public string Email
    {
        get { return _email; }
        set { _email = value; }
    }

    /// <summary>
    /// Address of user
    /// </summary>
    public string Address
    {
        get { return _address; }
        set { _address = value; }
    }

    /// <summary>
    /// FullName of user
    /// </summary>
    public string Fullname
    {
        get { return _fullname; }
        set { _fullname = value; }
    }

    /// <summary>
    /// Password of user
    /// </summary>
    public string Password
    {
        get { return _password; }
        set { _password = value; }
    }

    /// <summary>
    /// UserName used to log in
    /// </summary>
    public string UserName
    {
        get { return _username; }
        set { _username = value; }
    }

    #region IBusinessEntity Members
    /// <summary>
    /// Fill data from DataReader
    /// </summary>
    /// <param name="reader">Containts results of a query</param>
    public void Fill(System.Data.SqlClient.SqlDataReader reader)
    {
        UserName = reader.GetString(reader.GetOrdinal("Username"));
        Fullname = reader.GetString(reader.GetOrdinal("FullName"));
        Address = reader.GetString(reader.GetOrdinal("Address"));
        try
        {
            Email = reader.GetString(reader.GetOrdinal("Email"));
        }
        catch { }
        try
        {
            PhoneNumber = reader.GetString(reader.GetOrdinal("PhoneNumber"));
        }
        catch { }
        if (DAL.ColumnExists(reader, "PinCode"))
            PinCode = reader.GetString(reader.GetOrdinal("PinCode"));
        if (DAL.ColumnExists(reader,"BranchName"))
            BranchName = reader.GetString(reader.GetOrdinal("BranchName"));
        if (DAL.ColumnExists(reader,"IsWorking"))
            IsWorking = reader.GetBoolean(reader.GetOrdinal("IsWorking"));
        if (DAL.ColumnExists(reader, "Password"))
            Password = reader.GetString(reader.GetOrdinal("Password"));
    }

    #endregion
}
